/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import model.Cliente;

/**
 *
 * @author juliane
 */
public class ClienteDAO {
    
    private Connection con;
    private java.sql.PreparedStatement stmtInserir;
    
    public void ClienteDao() throws Exception{
        con = ConnectionFactory.getConnection();
    }
    
    public void ClienteDAO(Connection con){
        this.con = con;
    }
    
    public void inserir(Cliente cliente) throws Exception{
        stmtInserir = con.prepareStatement("INSERT INTO cliente(nome, sexo, data_nasc, cpf, endereco, numero, complemento, bairro, cep, cidade, estado, telefone, email) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
       
        stmtInserir.setString(1, cliente.getNome()); 
        stmtInserir.setString(2, cliente.getSexo());
        stmtInserir.setDate(3, new java.sql.Date(cliente.getData_nasc().getTime()));
        stmtInserir.setString(4, cliente.getCpf());
        stmtInserir.setString(5, cliente.getEndereco());
        stmtInserir.setInt(6, cliente.getNumero());
        stmtInserir.setString(7, cliente.getComplemento());
        stmtInserir.setString(8, cliente.getBairro());
        stmtInserir.setString(9, cliente.getCep());
        stmtInserir.setString(10, cliente.getCidade());
        stmtInserir.setString(11, cliente.getEstado());
        stmtInserir.setString(12, cliente.getTelefone());
        stmtInserir.setString(13, cliente.getEmail());
        
        stmtInserir.executeUpdate();
                }
}
